package com.aegean.MonitorExamSYS.conduction.action;

import javax.annotation.Resource;

import org.apache.struts2.ServletActionContext;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.aegean.MonitorExamSYS.conduction.business.ConductionBusiness;
import com.aegean.MonitorExaxSYS.model.ConductionValue;
import com.aegean.MonitorExaxSYS.model.MonitorValue;
import com.opensymphony.xwork2.ActionSupport;
@Controller("AddMonitorAction")
@Scope("prototype")
public class AddMonitorAction extends ActionSupport {
	@Resource
	ConductionBusiness business;
	private MonitorValue monitor;
	private int big_Id;
	private boolean success;
	private String msg;
	
	public int getBig_Id() {
		return big_Id;
	}
	public void setBig_Id(int big_Id) {
		this.big_Id = big_Id;
	}
	public MonitorValue getMonitor() {
		return monitor;
	}
	public void setMonitor(MonitorValue monitor) {
		this.monitor = monitor;
	}

	public boolean isSuccess() {
		return success;
	}
	public void setSuccess(boolean success) {
		this.success = success;
	}
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}
	public String add() throws Exception {
		// TODO Auto-generated method stub
		ConductionValue one=(ConductionValue)ServletActionContext.getRequest().getSession().getAttribute("ConductionLogin");
		monitor.setMonitor_Unit(one);
		monitor.setUser_Password("123456");
		monitor.setMonitor_State(1);
		success=business.addMonitorValue(monitor,big_Id);
		if(success==true){
			msg="添加监考人员成功，监考人员默认登录密码为“123456”！";
		}else{
			msg="对不起，监考人员添加失败，请核对信息或者联系考试中心！";
		}
		return SUCCESS;
	}
}
